Welcome to step two of our solution and here we are asked to create an appropriate index from nineteen
hundred and ninety seven until the end of the year 2008.
That best reflects the marriage strategy and to create a normalized price chart and we should get here
the stock price data from Yahoo Finance.
And let's have a look here again at the case.
So Marriott's is invested in the five most valuable health care stocks and her strategy is pretty simple.
She buys an equal number of shares of each stock and reinvest all dividends.
And we should create an index that best reflects strategy here.
And in this case that's a price weighted Performance Index in Step one we identify to the stock take
us for our five companies.
And here we have the US and now we should download historical price data from nineteen hundred ninety
seven.
So including the very last day of nineteen hundred ninety six until the end of 2018 and therefore we
create here two variables start and end with the respective dates and with the by finance library and
the download method we can actually download the historical price data and we pass here the tick our
list and the start and the end date and for our price where the performance index we are interested
in the columns the adjusted close and close and we save the data frame and the web of stocks
so that's uh the adjusted close and the close price for five stocks here beginning from the very last
day of nineteen hundred ninety six.
So typically here the download method of the finance library if you determine here the start date first
of January nineteen hundred ninety seven.
Then typically we get also the immediately preceding day or year the thirty first of December nineteen
hundred ninety six.
And our task is now to create a price weighted Performance Index and this can be done in few steps.
So first of all we have to calculate the weights of the constituents over time and we have to define
the weights with the closing prices and then we have to wait.
The daily returns based on the adjusted close prices with the weights that we derived in the first step
and by doing so we have the daily returns of our new index and as assets that we have to calculate the
cumulative investment multiple on each timestamp and calculate the index values also in each timestamp
based on a base value of 100 so let's start with the weights and we select the close prices and for
each and every time stand by for each and every row we divide each element and that row by the respective
some of the row and we safe actually hear the new resulting data frame and the variable weights.
And let's overlook so that's the respect for weights based on a price weighted strategy.
And initially in nineteen hundred ninety seven we can see that the highest weights we have for Mark
and let's go down here to 2000 and eighteen.
And we can see that we have the highest rates of 43 percent for the United test group actually.
So here
so that's the debates of our constituents over time and our new index.
And now in the next step we calculate the arc rate a return state of frame and therefore we choose that
the adjusted close prices to calculate the total return based on the assumption that the dividends will
be reinvested into the index and we calculate the daily return with uh the percentage change method.
And of course we also change the drop and a method.
So that's the return data frame and then the next step.
We calculate the daily returns of our index by evading the daily returns of the constituents with their
respective weights at the immediately preceding timestamp.
So that's what we are doing here.
And finally we calculate for each and every timestamp the cumulative investment multiple by adding 1
and using the Camp Road method here.
And finally as our base where you should be 100 we multiply each and every cumulative investment multiple
with 100 and we save our resulting index in the variable health index and let's have a look here.
So here we have a panel series with a index value of ninety nine point eight.
At the second of January nineteen hundred ninety seven.
So the first of January is a bank holiday so we do not have any values here.
And finally we should determine that on the very last timestamp all day of the year nineteen hundred
nineteen six we have the base value of one hundred and therefore we create here a timestamp for the
thirty first of December nineteen hundred ninety six and we actually create a new element for our as
serious here and we assign the value of one hundred and let's have again a look.
So here we cannot see the timestamp.
Thirty first of December nineteen hundred ninety six because it's still not sorted so here it's at the
very end and therefore in a next step we have to start the index.
And also here we pass true to the in-place parameter and we also assign a name to our panda series.
So that's the health care index.
And let's have a final look here.
So that's our large cap health care index that best reflects marries investment strategy starting with
a base value of 100 at the very last day of nineteen hundred ninety six.
And finally we end up here at the end of 2018 at eight hundred ninety.
So that's quite amazing actually.
And we can also plot here the evolution of the price of our index with the plot method
and we can see that from an initial base value of 100.
Mary could manage to increase her investment to a value of almost a 900.
So that's a pretty terrific year because our initial investment increased eight fold are almost nine
fold in only twenty two years.
So that was a very first analysis of our investment strategy and we will continue to do so in the next
video.
So I hope to see it there by.